/*
 * led.c
 * Project 4
 * Nicole Ang (nang1@asu.edu)
 * Bijan Fakhri (bfakhri@asu.edu)
 * CSE 325: Embedded Microprocessor Systems
 * Spring 2013
 */

#include "led.h"

int p_led;
int current_led; 

void led_init(){
	p_led = 1;
	gpio_led_init();
	
	//turn off all LEDs
	MCF_GPIO_CLRTC &= ~(1 << 0);
	MCF_GPIO_CLRTC &= ~(1 << 1);
	MCF_GPIO_CLRTC &= ~(1 << 2);
	MCF_GPIO_CLRTC &= ~(1 << 3);
	
}

void led_on(){
	MCF_GPIO_SETTC |= (1 << (p_led - 1));
	current_led = p_led;
	p_led++;
	if(p_led > 4)
		p_led = 1;
}

void led_off(){
	MCF_GPIO_CLRTC &= ~(1 << (p_led - 1));
}